package com.landeqing.controller;

import com.landeqing.model.BanJi;
import com.landeqing.model.Student;
import com.landeqing.service.BanJiService;
import com.sun.org.apache.xpath.internal.operations.Mod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("banji")
public class BanJIController {
    @Autowired
    private BanJiService banJiService;
    @RequestMapping("list")
    public ModelAndView getBanJiList(){
        ModelAndView mav=new ModelAndView("student/add");
        List<BanJi> list=banJiService.getList();
        for (BanJi c:list) {
            System.out.println(c.getClassName());
        }
        mav.addObject("list",list);
        return mav;

    }
/**
 *查询学生信息
 */
@RequestMapping("studentList")
    public  ModelAndView findAll(){
    List<BanJi> list=banJiService.getList();
    ModelAndView mav=new ModelAndView("/student/list");
    mav.addObject("list",list);
    return mav;
}
@RequestMapping("toClassList")
    public ModelAndView toClassList(){
        ModelAndView mav=new ModelAndView("banji/banjiList");
        List<BanJi> list=banJiService.getList();
        mav.addObject("list",list);
        return mav;
}
@RequestMapping("getById")
    public ModelAndView getById(Integer cid){
        ModelAndView mav=new ModelAndView("/banji/list");
        BanJi banJi=banJiService.getBanJiId(cid);
        return mav.addObject("banji",banJi);
}
}
